const zwJs = window.ZWJSBridge
//需要判断三端 浙里办app  微信小程序 支付宝小程序
export const phoneCall = (corpId) => {
    const sUserAgent = window.navigator.userAgent.toLowerCase()
    const bIsDtDreamApp = sUserAgent.indexOf('dtdreamweb') > -1 // 浙里办APP
    // 浙里办支付宝小程序
    if (!bIsDtDreamApp) {
        const a = document.createElement('a')
        a.style.display = 'none'
        a.href = 'tel:' + corpId
        a.click()
        a.remove()
    } else {
        return new Promise((resolve, reject) => {
            zwJs.onReady(() => {
                zwJs.phoneCall({ corpId }).then(res => {
                    resolve({ success: true, data: res })
                }).catch(error => {
                    resolve({ success: false, errMsg: JSON.stringify(error), data: {} })
                })
            })
        })
    }
}